package com.hl.sfzy.config;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;

@Component
/**
 * 配置日志
 */
public class LogbackConfig implements BeanFactoryPostProcessor {

    @Override
    public void postProcessBeanFactory(@NonNull ConfigurableListableBeanFactory beanFactory) throws BeansException {
        Logger rootLogger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
        rootLogger.setLevel(Level.DEBUG);
        ((Logger) LoggerFactory.getLogger("org.springframework.aop")).setLevel(Level.DEBUG);
        ((Logger) LoggerFactory.getLogger("com.hl.sfzy")).setLevel(Level.DEBUG);
        ((Logger) LoggerFactory.getLogger("org.springframework")).setLevel(Level.WARN);
        ((Logger) LoggerFactory.getLogger("org.mybatis")).setLevel(Level.INFO);
        ((Logger) LoggerFactory.getLogger("com.hl.sfzy.mapper")).setLevel(Level.DEBUG);
        ((Logger) LoggerFactory.getLogger("com.hl.sfzy.log.WebLogAspect")).setLevel(Level.DEBUG);
    }
}